<template>
  <view class="groupIncomeListMain">
    <view class="incomeListBox">
      <view v-if="list.length > 0">
        <view class="groupIncomelistItem" v-for="(item, index) in list" :key="index">
		 <view class="teamActiveBox">
			 <view>{{ item.number }}</view>
			 <view>{{ item.name }}</view>
			 <view class="tips">团队</view>
			 <view class="line"></view>
			 <view class="info flex align-center justify-between">
				 <view class="leftInfo">
				 	<view>所属代理：{{item.real_name}}</view>
				 	<view>商户名称：{{item.mercNm}}</view>
				 	<view>激活时间：{{$u.timeFormat(item.active_time, "yyyy-mm-dd hh:MM:ss")}}</view>
				 </view>
				 <view class="money"><text v-if="item.revert_money > 0">+</text>{{ item.revert_money }}</view>
			 </view>
		 </view> 
        </view>
      </view>
      <view class="noMachine flex align-center" v-if="list.length == 0 && isLoad">
        <image src="../../static/images/noData/zwjl.png" mode="widthFix"></image>
        <text>暂无收益</text>
      </view>
    </view>
    <u-loadmore
      :status="status"
      @loadmore="loadmore"
      v-if="list.length > 0"
      style="padding: 40rpx 0"
    />
    <toast></toast>
    <u-back-top :scroll-top="scrollTop"></u-back-top>
  </view>
</template>

<script>
export default {
  data() {
    return {
      scrollTop: 0,
      page: 1,
      limit: 10,
      list: [],
      status: "loadmore",
      noMore: false,
      isLoad: false,
	  searchDate:'',
    };
  },
  onLoad(options) {
	this.searchDate = options.yearDate
    this.groupIncomeList();
  },
  onPageScroll(e) {
    this.scrollTop = e.scrollTop;
  },
  onPullDownRefresh() {
    this.page = 1;
    this.list = [];
    this.status = "loadmore";
    this.noMore = false;
    this.isLoad = false;
    this.groupIncomeList();
  },
  onReachBottom() {
    if (this.noMore) {
      this.status = "nomore";
    } else {
      this.status = "loading";
      this.page = ++this.page;
      this.groupIncomeList();
    }
  },
  // 点击下载更多
  loadmore() {
    if (this.noMore) {
      this.status = "nomore";
    } else {
      this.page = ++this.page;
      this.status = "loadmore";
      this.groupIncomeList();
    }
  },
  methods: {
    groupIncomeList() {
      this.$u.api
        .zdfxGetGroupActiveIncomes({
          page: this.page,
          limit: this.limit,
		  searchMonth:this.searchDate
        })
        .then((res) => {
          if (res.status == 200) {
            let datas = res.result;
            if (this.page == 1 && datas.length == 0) {
              this.noMore == true;
              this.status = "nomore";
            }
            if (this.page == 1 && datas.length < this.limit) {
              this.noMore == true;
              this.status = "nomore";
            }
            if (this.page > 1 && datas.length < this.limit) {
              this.noMore == true;
              this.status = "nomore";
            }
            if (this.page > 1 && datas.length == this.limit) {
              this.status = "loading";
            }
            this.list = this.list.concat(datas);
          } else {
            this.$refs.uToast.show({
              title: res.msg,
              type: "error",
              duration: 1200,
            });
          }
          this.isLoad = true;
          uni.stopPullDownRefresh();
        })
        .catch((res) => {
          console.log(res);
          if (res.errMsg == "request:fail timeout") {
            this.$u.toast("请求超时，请重试!");
          } else if (res.errMsg == "request:fail") {
            this.$u.toast("请求失败，请重试");
          } else {
            this.$u.toast("请求失败，请重试");
          }
          this.$loading(false);
          setTimeout(() => {
            this.$u.route({
              type: "navigateBack",
              delta: 1,
            });
          }, 2000);
        });
    },
  },
};
</script>

<style lang="scss">
page {
  background: #fff;
}
.groupIncomeListMain {
  padding: 10rpx 30rpx 0;
  .groupIncomelistItem {
    padding: 20rpx 0;
	
	.teamActiveBox{
		position: relative;
		overflow: hidden;
		background-color: #fff;
		box-shadow: 0rpx 0rpx 8rpx #ccc;
		padding: 30rpx 30rpx 10rpx;
		border-radius: 10rpx;
		color: #000;
		font-family: numberFont;
		
		view{
			padding-bottom: 10rpx;
		}
		
		&>view:first-child{
			font-size: 36rpx;
			letter-spacing: 3rpx;
		}
		
		.line{
			width: 600rpx;
			height: 1rpx;
			background-color: #ececec;
			margin: 10rpx auto;
			padding: 0;
		}
		
		// &>view:nth-child(2)::after{
		// 	position: absolute;
		// 	top: 148rpx;
		// 	left: 80rpx;
		// 	content: '';
		// 	width: 540rpx;
		// 	height: 1rpx;
		// 	background-color: #ccc;
		// }
		
		.leftInfo{
			margin-top: 20rpx;
		}
		
		.info{
			.money{
				padding-right: 10rpx;
				color: #fb4535;
				font-weight: 700;
				font-size: 40rpx;
				letter-spacing: 3rpx;
			}
		}
		
		.tips{
			position: absolute;
			right: 0;
			top: 0;
			background-color: #fb4535;
			color: #fff;
			padding: 10rpx 20rpx 10rpx 24rpx;
			border-bottom-left-radius: 10rpx;
		}
	}

  }
}
</style>
